/* Copyright (C) 2014  Jean-Sebastien Castonguay
 *
 * This file is part of TechnoBoard.
 *
 * TechnoBoard is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TechnoBoard is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with TechnoBoard.  If not, see <http://www.gnu.org/licenses/>. */

#include "technoboard.h"
#include "usb_user.h"
#include "driver_timer.h"

#include <system.h>
#include <system_config.h>


void TechnoBoard_Initialise( TechnoBoard_Features features) {
 
    SYSTEM_Initialize(SYSTEM_STATE_USB_START);

    if (features & TECHNOBOARD_USB) {
        USBUser_Initialise();
    }

    if (features & TECHNOBOARD_TIMER) {
        DriverTimer_Init();
    }

    // TODO: Trouver une facon correct de setter
    // les bits qui mettent ls GPIO en digital mode (a l'oppose de analog...)
    AD1PCFG = 0x1FFF;
}


void TechnoBoard_CyclicProcess() {
    SYSTEM_Tasks();
    USBUser_Process();
}
